package com.hu.web.controller.business;

import com.hu.common.core.controller.BaseController;
import com.hu.common.core.domain.AjaxResult;
import com.hu.system.service.IDashboardService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 首页仪表盘Controller
 *
 * @author hu
 * @date 2025-01-22
 */
@RestController
@RequestMapping("/business/dashboard")
public class DashboardController extends BaseController {

    @Autowired
    private IDashboardService dashboardService;

    /**
     * 获取核心业务指标统计
     */
    @GetMapping("/statistics")
    public AjaxResult getStatistics() {
        return success(dashboardService.getStatistics());
    }

    /**
     * 获取采购趋势数据（最近30天）
     */
    @GetMapping("/purchaseTrend")
    public AjaxResult getPurchaseTrend() {
        return success(dashboardService.getPurchaseTrend());
    }

    /**
     * 获取产品状态分布
     */
    @GetMapping("/productStatus")
    public AjaxResult getProductStatus() {
        return success(dashboardService.getProductStatus());
    }

    /**
     * 获取库存预警列表（TOP10）
     */
    @GetMapping("/stockWarning")
    public AjaxResult getStockWarning() {
        return success(dashboardService.getStockWarning());
    }

    /**
     * 获取利润预警列表（TOP10）
     */
    @GetMapping("/profitWarning")
    public AjaxResult getProfitWarning() {
        return success(dashboardService.getProfitWarning());
    }
}

